//
//  PublicClass.m
//  Secret
//
//  Created by 隋文涛 on 13-12-11.
//  Copyright (c) 2013年 隋文涛. All rights reserved.
//

#import "PublicClass.h"

@implementation PublicClass

+ (NSString *)getPASSWORD{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    return [userDefaults stringForKey:@"PASSWORD"];
}

+ (void)setgetPASSWORDValue:(NSString *)Value{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setValue:Value forKey:@"PASSWORD"];
    [userDefaults synchronize];
    userDefaults = nil;
}

+ (NSTimeInterval)timeIntervalSince1970{
    return [[NSDate date] timeIntervalSince1970];
}

+ (NSString *)TimeFromInterval:(NSString *)Interval{
    @try {
        double timeInterval = [Interval doubleValue];
//        NSTimeInterval
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
        NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
        [outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        //    [outputFormatter setTimeZone:[NSTimeZone localTimeZone]];
        NSString *timestring = [outputFormatter stringFromDate:date];
        return timestring;
    }
    @catch (NSException *exception) {
        
    }
    @finally {
        
    }
    return @"";
}

+ (NSString *)GOTMD5PWwithstring:(NSString *) needmd5{
    const char *cStr = [needmd5 UTF8String];
    unsigned char result[32];
    CC_MD5( cStr, strlen(cStr), result);
    
    return [NSString stringWithFormat:
            @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
            result[0],result[1],result[2],result[3],
            result[4],result[5],result[6],result[7],
            result[8],result[9],result[10],result[11],
            result[12],result[13],result[14],result[15]
            ];
}

//+(BOOL)CurrentDeviceisIpad{
//    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
//        return NO;
//    return YES;
//}
@end
